Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
"Supplied parameters do not match any signature of call target." while using a get to gather information from API

I'm getting this error and i'm new to angular 2 so i'm not 100% sure on how to resolve the issue, i'm connecting to a test API to return a javascript object which includes some dummy data. But my "this.onGet()" function is telling me that the supplied parameter does not match any signature of call target and i can't seem to figure out why. (Essentially i'm just trying to populate the orderInfo array with the information from the API so i can use it across multiple page)

Any help appreciated :)

App.component.ts

    import { Component, OnInit } from '@angular/core';
import { DetailsService } from './details.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
    providers: [DetailsService]
})

export class AppComponent implements OnInit {
    orderInfo = [
        {
            name: 'Test'
        }
    ];
    constructor(private detailsService: DetailsService) {
    }

    ngOnInit() {
        this.onGet();
    }

    onGet(name: string) {
        this.detailsService.getDetails()
            .subscribe(
                (orderData: any[]) => {
                    this.orderInfo.push({
                        name: name
                    });
                    console.log(orderData);
                }
            );
    }
}

details.service.ts

import {Injectable} from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/Rx';

@Injectable()
export class DetailsService {
    constructor(private http: Http) {}
    getDetails() {
      return this.http.get('http://swapi.co/api/people/1/?format=json', '')
          .map(
              (response: Response) => {
                  const orderData = response.json();
                  return orderData;
              }
          );

    }
}
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The signature of http get method is

get(url: string, options?: RequestOptionsArgs) : Observable<Response>

You are passing a extra string parameter

 getDetails() {
        ///////////////removed below single quotes
        return this.http.get('http://swapi.co/api/people/1/?format=json')
          .map(
              (response: Response) => {
                  const orderData = response.json();
                  return orderData;
              }
          );

Look into your

 ngOnInit() {
        this.onGet(); //////////nothing passed
    }

where as your method signature is onGet(name:string) you are not passing anything as above

over 4 years ago · Santiago Trujillo Report

0

Your OnGet function is expecting a string parameter, which is not supplied while calling from ngOnInit.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!